package ch.hoth.java.joocal.actions;

import java.util.Date;

import ch.hoth.java.joocal.CalendarController;
import ch.hoth.java.joocal.DateUtil;

public class ChangeDateAction extends CalendarAction {
	
	public ChangeDateAction(String direction, CalendarController controller){
		super(direction, controller);
	}

	@Override
	public void run() {
		Date selectedDate = null;
		Date currentDate = getController().getSelectedDate();
		
		if (getText().equals("backward")){
			selectedDate = DateUtil.getPreviousDay(currentDate);
		}
		else if (getText().equals("forward")){
			selectedDate = DateUtil.getNextDay(currentDate);
			
		}
		else{
			selectedDate = new Date();
		}
		getController().setSelectedDate(selectedDate);
	}

}